package org.dbstar.scheduler.control.db.authority;

import java.sql.Types;

import org.dbstar.scheduler.beans.User;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.SqlParameter;
import org.springframework.jdbc.object.SqlUpdate;


/**
 * 删除user对应的所有授权
 * 
 * @author 代波
 * @since 1.0.0
 * @version 1.0.0
 * @date 2012-6-5
 */
public class AuthorityDelete extends SqlUpdate {
	public AuthorityDelete(JdbcTemplate jdbcTemplate) {
		super();
		setJdbcTemplate(jdbcTemplate);
		setSql("DELETE FROM SCHD_AUTHORITY WHERE USERNAME=?");
		declareParameter(new SqlParameter("USERNAME", Types.VARCHAR));
	}

	public int delete(User user) throws DataAccessException {
		return super.update(user.getUsername());
	}
}
